package personal.hrsw.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import personal.hrsw.mybatisplusdemo.domain.Student;
import personal.hrsw.mybatisplusdemo.service.StudentService;
import personal.hrsw.mybatisplusdemo.mapper.StudentMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【student】的数据库操作Service实现
* @createDate 2025-04-24 09:27:24
*/
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student>
    implements StudentService{
    @Autowired
    StudentMapper studentMapper;
    @Override
    public List<Student> findAll() {
        return studentMapper.selectAll();
    }

    @Override
    public int remove(int id) {
        return studentMapper.deleteById(id);
    }

    @Override
    public int add(Student student) {
        return studentMapper.insert(student);
    }

    @Override
    public Student findById(int id) {
        return studentMapper.selectById(id);
    }

    @Override
    public int edit(Student student) {
        return studentMapper.update(student);
    }

    @Override
    public List<Student> findByPage(int pageNo, int pageSize) {
        return studentMapper.selectByPage((pageNo-1)*pageSize, pageSize);
    }

    @Override
    public boolean login(String username, String password) {
        return studentMapper.selectByNameAndPwd(username,password)!=null;
    }
}




